home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_dejagnu.idb / usr / freeware / bin / runtest.z / runtest
Encoding:
Text File  |  1999-01-26  |  2.0 KB  |  90 lines

  1. #!/bin/sh
  2. #
  3. # runtest -- basically all this script does is find the proper expect shell and then
  4. #            run DejaGnu. <rob@cygnus.com>
  5. #
  6.  
  7. #
  8. # Get the execution path to this script and the current directory.
  9. #
  10. execpath=`echo ${0-.} | sed  -e 's@/[^/]*$@@'`
  11. # rootme=`pwd`
  12.  
  13. #
  14. # get the name by which runtest was invoked and extract the config triplet
  15. #
  16. runtest=`echo ${0-.} | sed -e 's@^.*/@@'`
  17. target=`echo $runtest | sed -e 's/-runtest$//'`
  18. if [ "$target" != runtest ] ; then
  19.     target="--target ${target}"
  20. else
  21.     target=""
  22. fi
  23.  
  24. #
  25. # Find the right expect binary to use. If a variable EXPECT exists,
  26. # it takes precedence over all other tests. Otherwise look for a freshly
  27. # built one, and then use one in the path.
  28. #
  29. if [ x"$EXPECT" != x ] ; then
  30.   expectbin=$EXPECT
  31. else
  32.   if [ -x "$execpath/expect" ] ; then
  33.     expectbin=$execpath/expect
  34.   else
  35.       expectbin=expect
  36.     fi
  37. fi
  38.  
  39. # just to be safe...
  40. if [ -z "$expectbin" ]; then
  41.   echo "ERROR: No expect shell found"
  42.   exit 1
  43. fi
  44.  
  45. #
  46. # Extract a few options from the option list.
  47. #
  48. verbose=0
  49. debug=""
  50. for a in "$@" ; do
  51.   case $a in        
  52.       -v|--v|-verb*|--verb*)    verbose=`expr $verbose + 1`;;
  53.       -D0|--D0)       debug="-D 0" ;;
  54.       -D1|--D1)       debug="-D 1" ;;
  55.   esac
  56. done
  57.  
  58. if expr $verbose \> 0 > /dev/null ; then
  59.   echo Expect binary is $expectbin
  60. fi
  61.  
  62. #
  63. # find runtest.exp. First we look in it's installed location, otherwise
  64. # start if from the source tree.
  65. #
  66. for i in $execpath/../lib/dejagnu $execpath ; do
  67.     if expr $verbose \> 1 > /dev/null ; then
  68.     echo Looking for $i/runtest.exp.
  69.     fi  
  70.     if [ -f $i/runtest.exp ] ; then
  71.     runpath=$i
  72.     if expr $verbose \> 0 > /dev/null ; then
  73.         echo Using $i/runtest.exp as main test driver
  74.     fi
  75.     fi
  76. done
  77. # check for an environment variable
  78. if [ x"$DEJAGNULIBS" != x ] ; then
  79.     runpath=$DEJAGNULIBS
  80.     if expr $verbose \> 0 > /dev/null ; then
  81.     echo Using $DEJAGNULIBS/runtest.exp as main test driver
  82.     fi
  83. fi
  84. if [ x"$runpath" = x ] ; then
  85.     echo "ERROR: runtest.exp does not exist."
  86.     exit 1
  87. fi
  88.  
  89. exec $expectbin $debug -- $runpath/runtest.exp $target ${1+"$@"}
  90.